//
//  ChannelLabel.m
//  555彩票
//
//  Created by zhoubo on 2017/7/4.
//  Copyright © 2017年 zhoubo. All rights reserved.
//

#import "ChannelLabel.h"

@implementation ChannelLabel

#define SelectedFont 18
#define NormalFont 14

+ (instancetype)labelWithTitle:(NSString *)title {
    // 创建 频道标签
    ChannelLabel *channelLabel = [[self alloc] init];
    // 设置字体
    channelLabel.font = [UIFont systemFontOfSize:SelectedFont];
    // 设置内容
    channelLabel.text = title;
    // 自适应大小 保证正确的宽高
    [channelLabel sizeToFit];
    // 设置可交互
    channelLabel.userInteractionEnabled = YES;
    
    channelLabel.textAlignment = NSTextAlignmentCenter;
    
    // 设置字体
    channelLabel.font = [UIFont systemFontOfSize:NormalFont];
    

    
    return channelLabel;
}

/**
 *  scale 0 到 1
 */
- (void)setScale:(CGFloat)scale {
    _scale = scale;
    
    //计算最大缩放比例
    CGFloat maxScale = (18-14)/14.0;
    CGFloat currentScale = 1 + maxScale * scale;
    

    self.transform = CGAffineTransformMakeScale(currentScale, currentScale);
    self.textColor = [UIColor colorWithRed:scale green:0 blue:0 alpha:1];
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    //    NSLog(@"xxxx= %@",self.text);
    if (self.selectedlabel) {
        self.selectedlabel();
    }
}

@end
